"""tb_user_roles changed

Revision ID: 0f41c1de6d50
Revises: b7fc7a0956e0
Create Date: 2025-10-29 12:39:50.345254

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = '0f41c1de6d50'
down_revision: Union[str, Sequence[str], None] = 'b7fc7a0956e0'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tb_user_roles',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('role_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['role_id'], ['tb_role_players.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['tb_users.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'role_id')
    )
    op.drop_table('t_user_roles')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('t_user_roles',
    sa.Column('user_id', mysql.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('role_id', mysql.INTEGER(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['role_id'], ['tb_role_players.id'], name=op.f('t_user_roles_ibfk_3')),
    sa.ForeignKeyConstraint(['user_id'], ['tb_users.id'], name=op.f('t_user_roles_ibfk_2')),
    sa.PrimaryKeyConstraint('user_id'),
    mysql_collate='utf8mb4_0900_ai_ci',
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    op.drop_table('tb_user_roles')
    # ### end Alembic commands ###
